package com.zbkj.admin.controller;

import com.zbkj.common.page.CommonPage;
import com.zbkj.common.request.AdminCashSearchRequest;
import com.zbkj.common.request.PageParamRequest;
import com.zbkj.common.response.CommonResult;
import com.zbkj.common.response.UserCashRecordResponse;
import com.zbkj.service.service.UserCashRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户礼金管理
 *
 * @author Swallows
 * @date 2022-09-26 11:07
 */
@Slf4j
@RestController
@RequestMapping("api/admin/user/cash")
@Api(tags = "用户礼金管理")
public class UserCashController {

    @Autowired
    private UserCashRecordService userCashRecordService;

    /**
     * 积分分页列表
     * @param request 搜索条件
     * @param pageParamRequest 分页参数
     */
    @PreAuthorize("hasAuthority('admin:user:cash:list')")
    @ApiOperation(value = "积分分页列表")
    @RequestMapping(value = "/list", method = RequestMethod.POST)
    public CommonResult<CommonPage<UserCashRecordResponse>> getList(@RequestBody @Validated AdminCashSearchRequest request, @Validated PageParamRequest pageParamRequest) {
        CommonPage<UserCashRecordResponse> restPage = CommonPage.restPage(userCashRecordService.findAdminList(request, pageParamRequest));
        return CommonResult.success(restPage);
    }
}
